package com.htjc.integral.house.util;

import com.htjc.integral.house.util.enums.AccountReturn;

/**
 * 自定义返回结果
 * @author zw
 */
public class ResultModel {
    /**
     * 返回码
     */
    private int code;

    /**
     * 返回结果描述
     */
    private String message;

    /**
     * 返回内容
     */
    private Object content;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getContent() {
        return content;
    }

    public ResultModel(int code, String message) {
        this.code = code;
        this.message = message;
        this.content = "";
    }

    public ResultModel(int code, String message, Object content) {
        this.code = code;
        this.message = message;
        this.content = content;
    }

    public ResultModel(ResultStatus status) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = "";
    }

    public ResultModel(ResultStatus status, Object content) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = content;
    }

    //积分数据处理中心
    public ResultModel(AccountReturn status) {
        this.code = status.getCode();
        this.message = status.getMsg();
        this.content = "";
    }

    //积分数据处理中心
    public ResultModel(AccountReturn status, Object content) {
        this.code = status.getCode();
        this.message = status.getMsg();
        this.content = content;
    }

    public static ResultModel ok(Object content) {
        return new ResultModel(ResultStatus.SUCCESS, content);
    }

    public static ResultModel ok() {
        return new ResultModel(ResultStatus.SUCCESS);
    }

    public static ResultModel error(ResultStatus error) {
        return new ResultModel(error);
    }

    public static ResultModel errorcontent(ResultStatus error, String content) {
        return new ResultModel(error, content);
    }

    /**
     * //积分数据处理中心返回成功
     *
     * @param content
     * @return
     */
    public static ResultModel AccountReturnSucceed(Object content) {
        return new ResultModel(AccountReturn.ACCOUNT_SUCCESS, content);
    }
    /**
     * //积分数据处理中心返回成功
     * @return
     */
    public static ResultModel AccountReturnSucceed() {
        return new ResultModel(AccountReturn.ACCOUNT_SUCCESS);
    }

    /**
     * //积分数据处理中心返回成功
     * @return
     */
    public static ResultModel AccountReturnSucceed(AccountReturn accountReturn) {
        return new ResultModel(accountReturn);
    }
    /**
     * //积分数据处理中心返回失败
     *
     * @param accountReturn
     * @return
     */
    public static ResultModel AccountReturnError(AccountReturn accountReturn) {
        return new ResultModel(accountReturn);
    }
}
